package com.qd.common.sys.domain.entity.station;

import com.cdqidi.valid.group.DefaultGroup;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.Optional;

/**
 * 人员岗位组织
 *
 * @author sjk
 */
@Getter
@Setter
@ToString
public class PersonStationOrgListDTO {

    /**
     * 机构ID
     */
    @NotBlank(message = "机构ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "机构ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String orgId;
    /**
     * 职责ID
     */
    @NotBlank(message = "职责ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "职责ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String stationId;
    /**
     * 人员列表
     */
    @NotNull(message = "人员列表不能为空", groups = DefaultGroup.class)
    private List<String> personList;

    public void freeData() {
        this.orgId = null;
        this.stationId = null;
        Optional.ofNullable(personList).ifPresent(List::clear);
    }
}
